package com.zengqingfa.examples.mybatisplus.context;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * @fileName: UserInfoContext
 * @author: zengqf3
 * @date: 2020-8-14 21:10
 * @description:
 */
public class UserInfoContext {

//    private static final ThreadLocal<String> USERCODE = new ThreadLocal<String>();
    private static final TransmittableThreadLocal<String> USERCODE = new TransmittableThreadLocal<>();

    public static String KEY_USERINFO_IN_HTTP_HEADER = "userCode";

    public UserInfoContext() {
    }

    public static String getUser() {
        return USERCODE.get();
    }

    public static void setUser(String userCode) {
        USERCODE.set(userCode);
    }

    public static void clear() {
        USERCODE.remove();
    }

}
